<template>
    <van-nav-bar title="分类" left-text="返回" left-arrow @click-left="onClickLeft" />
    <van-row>
        <van-col span="8">
            <van-sidebar v-model="active">
                <van-sidebar-item v-for="item in claData" :title="item.cat_name" />
            </van-sidebar>
        </van-col>
        <van-col span="16">
            <swipe :images="imageList"></swipe>
            <div v-for="item in claData[active]?.children">
                <h3>{{ item.cat_name }}</h3>
                <router-link :to="/goods/+item.cat_name" >
                    <van-grid :column-num="4">
                        <van-grid-item v-for="items in item.children" :icon="items.cat_icon" :text="items.cat_name" />
                    </van-grid>
                </router-link>
            </div>
        </van-col>>
    </van-row>

</template>

<script setup>
import router from '@/router';
const onClickLeft = () => {
    router.push('/')
}
import { categoriesApi } from '@/api/api';
import swipe from '@/components/swipe.vue';
import { ref } from 'vue';

let claData = ref([])
categoriesApi().then(res => {
    // console.log(res);
    claData.value = res.data.message

})
const active = ref(1)
const imageList = [
    'https://fastly.jsdelivr.net/npm/@vant/assets/apple-5.jpeg',
    'https://fastly.jsdelivr.net/npm/@vant/assets/apple-6.jpeg',
    'https://fastly.jsdelivr.net/npm/@vant/assets/apple-7.jpeg',
]
</script>

<style lang="scss" scoped></style>